home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / mg2a_src.zip / SYS / AMIGA / SYSINIT.C < prev    next >
C/C++ Source or Header  |  1988-08-23  |  1KB  |  64 lines

  1. /*
  2.  * Name:    MG 2a
  3.  *
  4.  *         Very early-on system-specific initialization for whatever's
  5.  *        necessary.
  6.  * Last edit:    05-May-88, Stephen Walton, swalton@solar.stanford.edu
  7.  * Created:    Stephen Walton, 3-Dec-87.
  8.  *    
  9.  */
  10. #include <libraries/dosextens.h>
  11. #include "sysdef.h"
  12.  
  13. #undef    FALSE
  14. #undef    TRUE
  15. #define    TRUE    1
  16. #define    FALSE    0
  17.  
  18. #ifdef USE_ARP
  19. struct Library    *ArpBase;
  20. extern struct    Library *OpenLibrary();
  21. #endif
  22.  
  23. #ifndef    NO_DIR
  24. extern struct    Task *FindTask();
  25. static BPTR    StartLock;
  26. char        MyDirName[MAXPATH];
  27. extern BPTR    DupLock(), CurrentDir();
  28. #endif NO_DIR
  29.  
  30. sysinit()
  31. {
  32.     long len;
  33.     BPTR MyDirLock;
  34.  
  35. #ifdef USE_ARP
  36.     if (!(ArpBase = OpenLibrary("arp.library", 0L)))
  37.         panic("Compiled with USE_ARP, but arp.library not found");
  38. #endif
  39. #ifndef NO_DIR
  40.     /*
  41.      * The following attempt to be clever assigns the external StartLock
  42.      * to the lock on the current directory, then switches our CurrentDir
  43.      * to a duplicate of that lock so we can restore the original lock
  44.      * on exit.
  45.      */
  46.  
  47.     StartLock = ((struct Process *)FindTask(0L))->pr_CurrentDir;
  48.     (void) CurrentDir(MyDirLock = DupLock(StartLock));
  49.     len = PathName(MyDirLock, MyDirName, MAXPATH/31L);
  50. #endif NO_DIR
  51. }
  52.  
  53. /*
  54.  * System dependent cleanup for the Amiga.
  55.  */
  56. syscleanup()
  57. {
  58.     UnLock(CurrentDir(StartLock));    /* restore startup directory    */
  59. #ifdef USE_ARP
  60.     if (ArpBase)
  61.         CloseLibrary(ArpBase);
  62. #endif
  63. }
  64.